﻿using UnityEngine;

namespace HurricanePackage
{
    /// <summary>
    /// UGUI窗体基类
    /// </summary>
    /// <typeparam name="V"></typeparam>
    public abstract class BasicUGUIWnd<V> : BasicWnd
    where V : BasicView
    {
        private V m_view;
        /// <summary>
        /// 视图
        /// </summary>
        protected  V View
        {
            get => m_view;
        }

        private RectTransform m_rect;
        /// <summary>
        /// 窗体rect
        /// </summary>
        protected RectTransform Rect
        {
            get
            {
                return m_rect;
            }
        }


        /// <summary>
        /// 该窗体的父节点
        /// </summary>
        protected abstract Transform ParentTransform { get; }


        protected GameObject m_gameObj;

        public override GameObject GetGameObj()
        {
            return m_gameObj;
        }

        /// <summary>
        /// 绑定View组件
        /// </summary>
        protected  void  _BandComponents(V _view)
        {
            
            m_view = _view;
            m_gameObj = _view.gameObject;
            m_rect = _view.GetComponent<RectTransform>();
        }

        /// <summary>
        /// 将窗体设为最后渲染(顶层)
        /// </summary>
        public void SetWndTop()
        {
            View.transform.SetAsLastSibling();
        }


        protected abstract void _OnInitDone();

        protected abstract void _OnShow();

        protected abstract void _OnHide();

        protected abstract void _OnReset();

        protected abstract void _OnDiscord();



    }
}